using System;
using UnityEngine;
using System.Collections.Generic;
using System.IO;
namespace GJXQGame
{
    public class GameManager : Singleton<GameManager>
    {
        private GUIManager   m_cGUIMgr;
        private SceneManager m_cSceneMgr;
        private ChessControl m_ChessControl;
        private ChessDataControl m_ChessDataControl;
        public string LogInfo;
        private float m_lastUpdateTime = 0.0f;

        public static SceneManager SceneManager { get { return GetInstance().GetSceneMgr(); } }
        public static GUIManager   GUIManager   { get { return GetInstance().GetGUIMgr();   } }

        public List<GUI_ID> DesGUIList = new List<GUI_ID>();

        public static ChessControl ChessControl { get { return GetInstance().GetChessControl(); } }
        public static ChessDataControl ChessDataControl { get { return GetInstance().GetChessDataControl(); } }

        public GameManager()
        {
            this.m_cGUIMgr = new GUIManager();
            this.m_cSceneMgr = new SceneManager();
            this.m_ChessControl = new ChessControl();
            this.m_ChessDataControl = new ChessDataControl();
           

        }

        public void Start()
        {
            this.GetGUIMgr().Start();
        }

        public void Destory()
        {
            this.m_cGUIMgr.Destory();
        }

        public GUIManager GetGUIMgr()
        {
            return this.m_cGUIMgr;
        }

        public SceneManager GetSceneMgr()
        {
            return this.m_cSceneMgr;
        }

        public ChessControl GetChessControl()
        {
            return this.m_ChessControl;
        }
        public ChessDataControl GetChessDataControl()
        {
            return this.m_ChessDataControl;
        }

        public void Initialize()
        {
            this.m_cGUIMgr.Initialize();
            this.m_cSceneMgr.Initialize();
            this.m_cSceneMgr.ChangeScene(SCENE_ID.SCENE_MAIN_HOME, SCENE_STYLE.NONE);
        }
       
        public void OnApplicationPause(bool isPause)
        {
           
        }

        public void OnApplicationQuit()
        {
            //SessionManager.GetInstance().OnApplicationQuit();
        }

        public void OnPressYesNo(bool isYes, object arg)
        {
            this.SignOut();
        }

        public bool Update()
        {
            if ((Time.time - m_lastUpdateTime) > 1.0f)
            {
                m_lastUpdateTime = Time.time;
            }
            m_cGUIMgr.Update();
            return true;
        }

        public void SignOut()
        {
            // Singleton<GUIGuideManager>.GetInstance().IsGuide = false;

            this.m_cGUIMgr.HidenAll();
            this.m_cSceneMgr.CurSceneID = SCENE_ID.SCENE_NONE;

            // this.m_cSceneMgr.ChangeLogin();
        }
        public static void CancelAllNotification()
        {

        }
    }
}
